#include <stdlib.h>
#include "logger.h"

/**
 */
inline int
mrr_mem_alloc(void **ptr, size_t size) {
	
	register void *p = malloc(size);
	if (p == 0) {
		mrr_fatal("Out of memory, requires %d bytes", size);
		return MRR_ERRNO_OUT_OF_MEMORY;
	}
	
	*ptr = p;
	
	return MRR_ERRNO_SUCCESS;
}

/**
 */
inline int
mrr_mem_realloc(void **ptr, size_t size) {

	register void *p = realloc(*ptr, size);
	if (p == 0) {
		mrr_fatal("Out of memory");
		return MRR_ERRNO_OUT_OF_MEMORY;
	}
	*ptr = p;
	
	return MRR_ERRNO_SUCCESS;
}

/**
 */
inline void 
mrr_mem_free(void *ptr) {

	free(ptr);
}
